package com.augurit.gzcgwsp.rqqyjyxk.convert;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dozer.DozerBeanMapper;

import com.augurit.common.util.lang.DateUtils;
import com.augurit.gzcgwsp.rqqyjyxk.entity.YwRqQyjyxk;
import com.augurit.gzcgwsp.rqqyjyxk.web.form.YwRqQyjyxkForm;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwRqQyjyxkForFx;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;

public class YwRqQyjyxkConvertor {
	public static YwRqQyjyxkForm convertVoToForm(YwRqQyjyxk entity) {
		 if (entity == null) return null;
		 
		 YwRqQyjyxkForm form = new DozerBeanMapper().map(entity, YwRqQyjyxkForm.class);
		    form.setAcceptNo2(entity.getAcceptNo());
			form.setCbyw2(entity.getCbyw());
			form.setCbyw3(entity.getCbyw());
			form.setCbyw4(entity.getCbyw());
			form.setSjr2(entity.getSjr());
			form.setSqdw2(entity.getSqdw());
			form.setSqrq(entity.getSarq());
			form.setSqrq2(DateUtils.dateTimeToString(entity.getSarq(), DateUtils.YEAR_MOUTH_DAY_));
//			form.setSqrq2(entity.getSqrq());
			if (entity.getSarq() != null) {
				form.setSqrq3(DateUtils.dateTimeToString(entity.getSarq(), DateUtils.YEAR_MOUTH_DAY_));
				form.setSqrq4(DateUtils.dateTimeToString(entity.getSarq(), DateUtils.YEAR_MOUTH_DAY_));
            }else{
				form.setSqrq3(DateUtils.dateTimeToString(new Date(), DateUtils.YEAR_MOUTH_DAY_));
				form.setSqrq4(DateUtils.dateTimeToString(new Date(), DateUtils.YEAR_MOUTH_DAY_));
            }
			form.setCurDate(DateUtils.dateTimeToString(new Date(), DateUtils.YEAR_MOUTH_DAY_));
			form.setCurDate2(form.getCurDate());
			form.setCurDate3(form.getCurDate());
			form.setBszsbh(entity.getZsbh());
		  return form;
	}
	
	public static void convertFormToVo(YwRqQyjyxkForm form, YwRqQyjyxk entity) {
        if (form == null) return;
        if (entity == null) 
            entity = new YwRqQyjyxk();
        new DozerBeanMapper().map(form, entity);
        entity.setZsbh(form.getZsbh());
	}
	
	public static List<YwRqQyjyxkForm> convertVoListToFormList(List<YwRqQyjyxk> ywRqQyjyxkList) {
		if(ywRqQyjyxkList != null && ywRqQyjyxkList.size() > 0) {
			List<YwRqQyjyxkForm> ywRqQyjyxkFormList = new ArrayList();
			for(int i=0; i<ywRqQyjyxkList.size(); i++) {
				ywRqQyjyxkFormList.add(convertVoToForm(ywRqQyjyxkList.get(i)));
			}
			return ywRqQyjyxkFormList;
		}
		return null;
	}
	
	public static List<Map> convertVoListToMapList(List<YwRqQyjyxk> ywRqQyjyxkList) {
		if(ywRqQyjyxkList != null && ywRqQyjyxkList.size() > 0) {
			List<Map> mapList = new ArrayList();
			for(int i=0; i<ywRqQyjyxkList.size(); i++) {
				YwRqQyjyxk entity = ywRqQyjyxkList.get(i);
				Map<String, String> map = new HashMap();

				map.put("jGyzmc", entity.getJGyzmc());
				map.put("jGyzdz", entity.getJGyzdz());
				map.put("jZyfzr", entity.getJZyfzr());
				map.put("jAqfzr", entity.getJAqfzr());
				map.put("jLxdh", entity.getJLxdh());
				map.put("jCz", entity.getJCz());
				map.put("jYyzzzch", entity.getJYyzzzch());
				map.put("jXfyswj", entity.getJXfyswj());
				map.put("jJgysrq", DateUtils.dateTimeToString(entity.getJJgysrq(), "yyyy-MM-dd"));
				map.put("jGczj", entity.getJGczj() == null ? "" : entity.getJGczj().toString());
				map.put("jYdzl", entity.getJYdzl());
				map.put("jZdmj", entity.getJZdmj() == null ? "" : entity.getJZdmj().toString());
				map.put("jAzxs", entity.getJAzxs());
				map.put("jCgsl", entity.getJCgsl() == null ? "" : entity.getJCgsl().toString());
				map.put("jCgzrj", entity.getJCgzrj() == null ? "" : entity.getJCgzrj().toString());
				map.put("jDgzdrj", entity.getJDgzdrj() == null ? "" : entity.getJDgzdrj().toString());
				map.put("jGzsbXh", entity.getJGzsbXh());
				map.put("jGzsbSl", entity.getJGzsbSl() == null ? "" : entity.getJGzsbSl().toString());
				map.put("jGzsbBys", entity.getJGzsbBys() == null ? "" : entity.getJGzsbBys().toString());
				map.put("jTbxXh", entity.getJTbXh());
				map.put("jTbxSl", entity.getJTbSl() == null ? "" : entity.getJTbSl().toString());
				map.put("jTbxBys", entity.getJTbBys() == null ? "" : entity.getJTbBys().toString());
				map.put("jYsjXh", entity.getJYsjXh());
				map.put("jYsjSl", entity.getJYsjSl() == null ? "" : entity.getJYsjSl().toString());
				map.put("jYsjBys", entity.getJYsjBys() == null ? "" : entity.getJYsjBys().toString());
				map.put("jWyickxtXh", entity.getJWyickxtXh());
				map.put("jWyickxtSl", entity.getJWyickxtSl() == null ? "" : entity.getJWyickxtSl().toString());
				map.put("jWyickxtBys", entity.getJWyickxtBys() == null ? "" : entity.getJWyickxtBys().toString());
				map.put("jSpjkxtXh", entity.getJSpjkxtXh());
				map.put("jSpjkxtSl", entity.getJSpjkxtSl() == null ? "" : entity.getJSpjkxtSl().toString());
				map.put("jSpjkxtBys", entity.getJSpjkxtBys() == null ? "" : entity.getJSpjkxtBys().toString());
				map.put("gGyzdz", entity.getGGyzdz());
				map.put("gZyfzr", entity.getGZyfzr());
				map.put("gAqfzr", entity.getGAqfzr());
				map.put("gLxdh", entity.getGLxdh());
				map.put("gCz", entity.getGCz());
				map.put("gYyzzzch", entity.getGYyzzzch());
				map.put("gXfyswh", entity.getGXfyswh());
				map.put("gGyzdj", entity.getGGyzdj() == null ? "" : entity.getGGyzdj().toString());
				map.put("gZdmj", entity.getGZdmj() == null ? "" : entity.getGZdmj().toString());
				map.put("gGyzmc", entity.getGGyzmc());
				map.put("gCscqr", entity.getGCscqr());
				map.put("gZlhtbah", entity.getGZlhtbah());
				map.put("id", entity.getId() == null ? "" : entity.getId().toString());
				map.put("sqdw", entity.getSqdw());
				map.put("zcdz", entity.getZcdz());
				map.put("yzbm", entity.getYzbm());
				map.put("clsj", DateUtils.dateTimeToString(entity.getClsj(), "yyyy-MM-dd"));
				map.put("yyzzzch", entity.getYyzzzch());
				map.put("lxdh", entity.getLxdh());
				map.put("cz", entity.getCz());
				map.put("qywz", entity.getQywz());
				map.put("dzyx", entity.getDzyx());
				map.put("fddbr", entity.getFddbr());
				map.put("fddbrZw", entity.getFddbrZw());
				map.put("fddbrZc", entity.getFddbrZc());
				map.put("zyfzr", entity.getZyfzr());
				map.put("zyfzrZw", entity.getZyfzrZw());
				map.put("zyfzrZc", entity.getZyfzrZc());
				map.put("aqfzr", entity.getAqfzr());
				map.put("aqfzrZw", entity.getAqfzrZw());
				map.put("aqfzrZc", entity.getAqfzrZc());
				map.put("jsfzr", entity.getJsfzr());
				map.put("jsfzrZw", entity.getJsfzrZw());
				map.put("jsfzrZc", entity.getJsfzrZc());
				map.put("qyzczb", entity.getQyzczb() == null ? "" : entity.getQyzczb().toString());
				map.put("qylx", entity.getQylx() == null ? "" : entity.getQylx().toString());
				map.put("jyfw", entity.getJyfw());
				map.put("gqqy", entity.getGqqy());
				map.put("fwdh", entity.getFwdh());
				map.put("qxdh", entity.getQxdh());
				map.put("qyjj", entity.getQyjj());
				map.put("acceptNo", entity.getAcceptNo());
				map.put("sjr", entity.getSjr());
				map.put("sarq", DateUtils.dateTimeToString(entity.getSarq(), "yyyy-MM-dd"));
				map.put("cbyw", entity.getCbyw());
				map.put("lxr", entity.getLxr());
				map.put("cbbm", entity.getCbbm());
				map.put("hbbm", entity.getHbbm());
				map.put("cpsj", DateUtils.dateTimeToString(entity.getCpsj(), "yyyy-MM-dd"));
				map.put("dfsj", DateUtils.dateTimeToString(entity.getDfsj(), "yyyy-MM-dd"));
				map.put("jbrxm", entity.getJbrxm());
				map.put("sendNotice", entity.getSendNotice());
				map.put("yslNo", entity.getYslNo());
				map.put("businessCode", entity.getBusinessCode());
				map.put("approvalNo", entity.getApprovalNo());
				map.put("ysl", entity.getYsl() == null ? "" : entity.getYsl().toString());
				map.put("jarq", DateUtils.dateTimeToString(entity.getJarq(), "yyyy-MM-dd"));
				map.put("jar", entity.getJar());
				map.put("larq", DateUtils.dateTimeToString(entity.getLarq(), "yyyy-MM-dd"));
				//考核
				map.put("khslhmc1", entity.getKhslhmc1());
				//设置套打时间
				map.put("startyear", entity.getStartyear());
				map.put("startmonth", entity.getStartmonth());
				map.put("startday", entity.getStartday());
				map.put("endyear", entity.getEndyear());
				map.put("endmonth", entity.getEndmonth());
				map.put("endday", entity.getEndday());
				map.put("fzjg", entity.getFzjg());
				map.put("zsbh", entity.getZsbh());
				mapList.add(map);
			}
			return mapList;
		}
		return null;
	}
	
	public static List<YwRqQyjyxk> convertFormListToVoList(List<YwRqQyjyxkForm> ywRqQyjyxkFormList) {
		if(ywRqQyjyxkFormList != null && ywRqQyjyxkFormList.size() > 0) {
			List<YwRqQyjyxk> ywRqQyjyxkList = new ArrayList();
			for(int i=0; i<ywRqQyjyxkFormList.size(); i++) {
				YwRqQyjyxk ywRqQyjyxk = new YwRqQyjyxk();
				convertFormToVo(ywRqQyjyxkFormList.get(i), ywRqQyjyxk);
				ywRqQyjyxkList.add(ywRqQyjyxk);
			}
			return ywRqQyjyxkList;
		}
		return null;
	}
	
	public static void convertFormToQyxxForm(YwRqQyjyxkForm form, YwComQyxxForm qyxxForm) {
	    if (form == null) return;
	    if (qyxxForm == null) qyxxForm = new YwComQyxxForm();

        new DozerBeanMapper().map(form, qyxxForm);
        qyxxForm.setId(form.getQyid());
	}
	
    public static void convertQyxxFormToForm(YwComQyxxForm qyxxForm, YwRqQyjyxkForm form) {
        if (qyxxForm == null) return;
        if (form == null) form = new YwRqQyjyxkForm();
        
        new DozerBeanMapper().map(qyxxForm, form);
        form.setQyid(qyxxForm.getId());
    }
    
    public static void convertFormToYwRqQyjyxkForFx(YwRqQyjyxkForm form, YwRqQyjyxkForFx entity) {
        if (form == null) return;
        if (entity == null) 
            entity = new YwRqQyjyxkForFx();
        new DozerBeanMapper().map(form, entity);
	}

    
    
}